import type { Res } from '#/global'

export function usePage(reload: () => void) {
  const page = reactive<Res.Page>({
    PageNum: 1,
    PageSize: 20,
    RecordsetCount: 0,
  })

  const pageNumChange = (pageNum: number) => {
    page.PageNum = pageNum
    reload()
  }

  const pageSizeChange = (pageSize: number) => {
    page.PageSize = pageSize
    page.PageNum = 1
    reload()
  }

  return {
    page,
    pageNumChange,
    pageSizeChange,
  }
}
